﻿using System;
using System.Collections.Generic;
using System.Text;

using MT.eVotePRS.Model;
using MT.eVotePRS.Service;
using MT.eVotePRS.Presentation.Core;

namespace MT.eVotePRS.Presentation.Logic
{
    public class StudentActions : AbstractForm
    {
        StudentInfo _student = null;

        private static readonly StudentInfoService _studentService = StudentInfoService.GetInstance();

        public StudentActions()
            : base()
        {
            _student = new StudentInfo();
        }

        public StudentInfo Student
        {
            get { return _student; }
            set { _student = value; }
        }

        public object CreateNewStudent()
        {
            return _studentService.InsertStudent(_student);
        }

        public StudentInfo FindStudentByBarcode(string barcode)
        {
            _student = _studentService.GetStudentByBarcode(barcode);
            return _student;
        }

        public StudentInfo FindStudentByNo(string studentNo)
        {
            _student = _studentService.GetStudentByNo(studentNo);
            return _student;
        }

        public void UpdateStudent()
        {
            _studentService.UpdateStudentInfoById(_student);
        }
    }
}
